package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory3;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	/**
	 * 内部调用接口 1106 查询指定一级分类下前7个三级分类数据
	 * @param category1Id
	 * @return
	 */
	@GetMapping("/getBaseCategory3List/{category1Id}")
	List<BaseCategory3> getBaseCategory3List(@PathVariable("category1Id") Long category1Id){
		return baseCategoryService.findTopBaseCategory3(category1Id);
	}

	/**
	 * 1106 查询指定一级分类下前7个三级分类数据
	 * @param category1Id
	 * @return
	 */
	@GuiguLogin
	@GetMapping("/findTopBaseCategory3/{category1Id}")
	public Result findTopBaseCategory3(@PathVariable("category1Id") Long category1Id){
		return Result.ok(baseCategoryService.findTopBaseCategory3(category1Id));
	}

	/**
	 * 1106 查询指定一级分类下全部的分类数据
	 * @param category1Id
	 * @return
	 */
	@GuiguLogin
	@GetMapping("/getBaseCategoryList/{category1Id}")
	public Result getBaseCategoryList(@PathVariable("category1Id") Long category1Id){
		return Result.ok(baseCategoryService.getAllBaseCategoryListById(category1Id));
	}
    /**
	 * 查询所有的分类数据
     * @param
     * @return null
     */
	@GuiguLogin
	@GetMapping("/getBaseCategoryList")
	public Result getBaseCategoryList(){
		return Result.ok(baseCategoryService.getBaseCategoryList());
	}

	/**
	 * 根据一级分类Id查询所有的标签数据
	 * @return
	 */
	@GuiguLogin
	@Operation(tags = "根据一级分类Id查询所有的标签数据")
	@GetMapping("findAttribute/{category1Id}")
	public Result<List<BaseAttribute>> findAttribute(@PathVariable(value = "category1Id") Long category1Id){
		return Result.ok(baseCategoryService.findAttribute(category1Id));
	}

}

